#ifndef SPOT_H
#define SPOT_H

#include <QWidget>
#include <QPainter>
#include <functional>
class Spot : public QWidget
{
    Q_OBJECT

public:
    explicit Spot(QWidget *parent = nullptr);
    ~Spot();

private:
    void mousePressEvent(QMouseEvent *event) override;
    void mouseReleaseEvent(QMouseEvent *event) override;
    void mouseMoveEvent(QMouseEvent *event) override;

    void paintEvent(QPaintEvent *) override;
public:
    void dragable(bool candrag);

    void focusout();

    QPoint getpos() const;
    const QRect& getrect() const;
    int radius() const;

    void setpos(const QPoint& pos);
    void setradius(int r);

    void setpainter(const std::function<void(QPainter&)>& f_setpainter){_f_setpainter = f_setpainter;}

private:
    bool _mousepressed = false;

    QPoint _oldpos;
    QPoint _oldmousepos;

    std::function<void(QPainter&)> _f_setpainter;
private:
    int _radius;
};

#endif // SPOT_H
